package com.abaaba.project2.aspect;

import com.abaaba.project2.bean.vo.BaseRespVo;
import com.abaaba.project2.service.AdminLogService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


//只针对登录登出以及管理员相关操作
@Aspect
@Component
public class LogAspect {

    @Autowired
    AdminLogService adminLogService;


    @Pointcut("@annotation(com.abaaba.project2.aspect.Log)")
    public void systemAndLogPointcut() {
    }
    @Around("systemAndLogPointcut()")
    public BaseRespVo systemLogCreate(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {

        BaseRespVo respVo = (BaseRespVo) proceedingJoinPoint.proceed();

        adminLogService.systemLogCreate(respVo, proceedingJoinPoint);

        return respVo;
    }

}
